package com.neuedu.it.teach.controller;

import com.neuedu.it.teach.controller.vo.Result;
import com.neuedu.it.teach.entity.TeacherResume;
import com.neuedu.it.teach.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/*TODO: 完成老师表的增删查改，
   没有增加
   查的时候，分查询自己的全部情况，还有连表的查（这个我写）
   删除，没有
   改，没有
*  */
/**
 -- 4. 教师个人简历表（仅针对教师用户）
 DROP TABLE IF EXISTS `teacher_resume`;
 CREATE TABLE `teacher_resume` (
 `resume_id` INT NOT NULL AUTO_INCREMENT,
 `teacher_id` INT NOT NULL,           -- 关联用户表中教师的 user_id
 `bio` TEXT,                          -- 个人简介
 `education` VARCHAR(255),            -- 学历信息
 `experience` TEXT,                   -- 教学或工作经验
 `certificates` TEXT,                 -- 获奖经历
 `profile_picture` VARCHAR(255),      -- 头像或照片链接
 `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
 PRIMARY KEY (`resume_id`),
 FOREIGN KEY (`teacher_id`) REFERENCES `users`(`user_id`) ON DELETE CASCADE,
 UNIQUE KEY `teacher_unique` (`teacher_id`)  -- 每个教师仅有一份简历
 ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;

 SET FOREIGN_KEY_CHECKS = 1;
 * *
 */

@RestController
@RequestMapping("/teacher")
public class TeachController {
    @Autowired
    private TeacherService teacherService;

    /**
     * 根据教师 id 查询教师个人简历
     * @param teacherId 教师 id
     * @return TeacherResume
     */
    @GetMapping("/{teacherId}")//已测试
    public Result getTeacherResume(@PathVariable Integer teacherId) {
        TeacherResume data = teacherService.getTeacherResumeById(teacherId);
        if (data == null) {
            return Result.badRequest("Teacher resume not found");
        }
        return Result.success(data);
    }
}
